<template>
    <div>
      <div class="title" v-if='source.name'>{{source.name}}</div>
      <ul class="list">
        <li class="cateItem" @click="toSubCateList(category)" v-for="category in source.categoryList" :key="category.id">
          <div>
            <div class="itemImg">
              <img :src="category.wapBannerUrl" alt="">
            </div>
            <div class="name">{{category.name}}</div>
          </div>
        </li>
      </ul>
    </div>
</template>

<script>
export default {
  name: 'Item',
  props: {
    index: { // index of current item
      type: Number
    },
    source: { // here is: {uid: 'unique_1', text: 'abc'}
      type: Object,
      default () {
        return {}
      }
    }
  },

  methods: {
    toSubCateList(category) {
      this.$router.push({
        path: '/subcateList',
        query: {
          categoryId: category.superCategoryId,
          subCategoryId: category.id,
          categoryType: category.categoryType,
        }
      });
    }
  },
}
</script>
